import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    name:'home',
    redirect:'/login',
    meta:{
      title:'原神 ——后台管理系统'
    }
  },
  {
    path:'/login',
    name:'login',
    component:()=>import('../views/Login.vue'),
    meta:{
      title:'后台管理系统 ——管理员登录'
    }
  },
  {
    path:'/loginsucc',
    name:'loginsucc',
    component:()=>import('../views/Index.vue'),
    meta:{
      title:'原神 ——后台管理系统'
    },
    redirect:'/loginsucc/index',
    children:[
      {
        path:'index',
        name:'index',
        component:()=>import('../views/Home.vue'),
        meta:{
          title:'首页 —后台管理'
        }
      },
      {
        path:'Userlist',
        name:'Userlist',
        component:()=>import('../views/Userlist.vue'),
        meta:{
          title:'用户列表'
        }
      },
      {
        path:'news_list',
        name:'news_list',
        component:()=>import('../views/Newlist.vue'),
        meta:{
          title:'新闻列表'
        }
      },
      {
        path:'update_password',
        name:'update_password',
        component:()=>import('../views/User_password.vue'),
        meta:{
          title:'修改密码'
        }
      },
      {
        path:'add_news',
        name:'add_news',
        component:()=>import('../views/AddNews.vue'),
        meta:{
          title:'原神 —添加新闻'
        }
      },
      {
        path:'add_admin',
        name:'add_admin',
        component:()=>import('../views/Add_Admin.vue'),
        meta:{
          title:'原神 —添加管理员账号'
        }
      },
      {
        path:'adminList',
        name:'adminList',
        component:()=>import('../views/AdminList.vue'),
        meta:{
          title:'原神 ——管理员列表'
        }
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to,meta,next)=>{
  document.title=to.meta.title
  next()
})
export default router
